home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / bbs / fcfgw40s.zip / SELECTGR.CPP < prev    next >
C/C++ Source or Header  |  1996-04-17  |  2KB  |  81 lines

  1. // SelectGroup.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "FileCFG.h"
  6. #include "SelectGroup.h"
  7. #include "proboard.h"
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CSelectGroup dialog
  19.  
  20. const char *CSelectGroup::strNoName = "╖╖╖<empty definition>╖╖╖";
  21.  
  22.  
  23. CSelectGroup::CSelectGroup(CWnd* pParent /*=NULL*/)
  24.     : CDialog(CSelectGroup::IDD, pParent)
  25. {
  26.     //{{AFX_DATA_INIT(CSelectGroup)
  27.     m_SelectAll = FALSE;
  28.     m_GroupNum = -1;
  29.     //}}AFX_DATA_INIT
  30. }
  31.  
  32.  
  33. void CSelectGroup::DoDataExchange(CDataExchange* pDX)
  34. {
  35.     CDialog::DoDataExchange(pDX);
  36.     //{{AFX_DATA_MAP(CSelectGroup)
  37.     DDX_Control(pDX, IDC_LIST_GROUPS, m_GroupList);
  38.     DDX_Check(pDX, IDC_CHECK_INCLUDE_ALL, m_SelectAll);
  39.     DDX_LBIndex(pDX, IDC_LIST_GROUPS, m_GroupNum);
  40.     //}}AFX_DATA_MAP
  41. }
  42.  
  43.  
  44. BEGIN_MESSAGE_MAP(CSelectGroup, CDialog)
  45.     //{{AFX_MSG_MAP(CSelectGroup)
  46.     //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CSelectGroup message handlers
  51.  
  52. BOOL CSelectGroup::OnInitDialog() 
  53. {
  54.     char       path[_MAX_PATH];
  55.     TFileGroup group;
  56.     CFile      file;
  57.  
  58.     CDialog::OnInitDialog();
  59.  
  60.     sprintf(path, "%s\\FGROUPS.PB", getenv("PROBOARD"));
  61.     if( !file.Open(path, CFile::modeRead|CFile::typeBinary|CFile::shareDenyWrite) ){
  62.         MessageBox("Could not open the group defintion file.","FileCFG/95",MB_OK|MB_ICONSTOP);
  63.         OnCancel();
  64.         return TRUE;    // not really needed, never hits it
  65.     }
  66.     UINT nBytes = file.Read(&group, sizeof(group));
  67.     while( nBytes == sizeof(group) ){
  68.         if( '\0' == group.name[0] ){
  69.             m_GroupList.AddString(strNoName);
  70.         }
  71.         else{
  72.             CString name = group.name;
  73.             name.OemToAnsi();
  74.             m_GroupList.AddString(name);
  75.         }
  76.         nBytes = file.Read(&group, sizeof(group));
  77.     }
  78.     file.Close();
  79.     return TRUE;
  80. }
  81.